<?php

//MODELE



abstract class Modele {

    protected $mysql;

    public function __construct() {
        try {

            $this->mysql = new PDO(SERVER, USER, PASSWORD);
        } catch (PDOException $e) {
            echo"Erreur de connexion au serveur :<br>" . $e->getMessage() . "<br>";
        }
    }

}

class AfficherListeContact extends Modele {

    public function select($table, $champs) {

        $sql = "SELECT $champs FROM $table";

        $req = $this->mysql->prepare($sql);

        $req->execute();

        while ($data = $req->fetch(PDO::FETCH_ASSOC)) {

            $result[] = $data;
        }
        return $result;
    }

}
